﻿using System;
using System.Collections.Generic;
using System.Text;
using DTO;
using DAO;

namespace BUS
{
    public class BC_MDP_BUS
    {
        public static void LapBC(long mBC, long tBC)
        {
            BC_MDP_DAO.LapBC(mBC, tBC);

            List<PhongDTO> P = PhongBUS.TraCuuTatCa();

            for (int i = 0; i < P.Count; i++)
            {
                BC_MDP_ChiTietBUS.LapCTBC(mBC, P[i].MaPhong);
            }
        }

        public static bool UpdateTSN(long mBC, long tSN)
        {
            return BC_MDP_DAO.UpdateTSN(mBC, tSN);
        }

        public static bool KtMaBC(long mBC)
        {
            return BC_MDP_DAO.KtMaBC(mBC);
        }

        public static long TinhTSN(long mBC, long tBC)
        {
            BC_MDP_ChiTietBUS.TinhSN(mBC, tBC);

            List<BC_MDP_ChiTietDTO> L = BC_MDP_ChiTietBUS.LayDSTheoMBC(mBC);
            long tSN = 0;

            for (int i = 0; i < L.Count; i++)
            {
                tSN = tSN + L[i].SoNgayThue;
            }

            BC_MDP_DAO.UpdateTSN(mBC, tSN);

            return tSN;
        }
    }
}
